
import java.util.*;
import java.io.*;

public class tests2 {

    public static void main(String args[]) {

        List<Graph> tests = new ArrayList();
        Graph test = Graph.kgraphgen(5);;
        double eta = 0.1;
        String log="default_test.log";

        if(args.length == 4){
          if(args[0].compareToIgnoreCase("kkgraph") == 0){
            test = Graph.kkgraphgen(Integer.parseInt(args[1]),Integer.parseInt(args[2]));
            eta = Double.parseDouble(args[3]);
            log="kkgraph_"+args[1]+"_"+args[2]+"_"+args[3]+".log";
          }
        }
        else if(args.length == 3){
          if(args[0].compareToIgnoreCase("kgraph") == 0){
            test = Graph.kgraphgen(Integer.parseInt(args[1]));
            eta = Double.parseDouble(args[2]);
            log="kgraph_"+args[1]+"_"+args[2]+".log";

          }
          else if(args[0].compareToIgnoreCase("cycle") == 0){
            test = Graph.cgen(Integer.parseInt(args[1]));
            eta = Double.parseDouble(args[2]);
            log="cycle_"+args[1]+"_"+args[2]+".log";
          }
          else if(args[0].compareToIgnoreCase("wheel") == 0){
            test = Graph.wgen(Integer.parseInt(args[1]));
            eta = Double.parseDouble(args[2]);
            log="wheel_"+args[1]+"_"+args[2]+".log";
          }
          else if(args[0].compareToIgnoreCase("file") == 0){
            test = new Graph(args[1]);
            eta = Double.parseDouble(args[2]);
            log=args[1]+"_"+args[2]+".log";
          }
        }

        /*tests.add(new Graph("ourgraph19.txt"));
        System.out.println("graph1 added");
        tests.add(new Graph("ourgraph19B.txt"));
        System.out.println("graph1 added");*/
/*
ourgraph19.txt = 43799735, completed in 68 seconds
ourgraph19B.txt = 19807203, completed in 30 seconds
line (39) = 102334154, completed in 34 seconds
bipartite (9,9) = 17572113, completed in 21 seconds
Complete (16) = 46206735, completed in 100 seconds
bipartite (1,2000) = 2000, completed in 2 seconds
bipartite (8,12) = 76751232, completed in 100 seconds
cycle (38) = 87403802, completed in 34 seconds
wheel (30) = 12857077, completed in 41 seconds
random15.txt = 202152, completed in 0 seconds
random20A.txt = 2219652, completed in 2 seconds
random20B.txt = 353703, completed in 0 seconds

*/

        /*tests.add(Graph.lgen(39));
//tests.append( tgen(25))
        tests.add(Graph.kkgraphgen(9, 9));
        tests.add(Graph.kgraphgen(16));
        tests.add(Graph.kkgraphgen(1, 2000));
        tests.add(Graph.kkgraphgen(8, 12));
        tests.add(Graph.cgen(38));
        tests.add(Graph.wgen(30));
*/

/*
        tests.add(new Graph("random15.txt"));
        tests.add(new Graph("random20A.txt"));
        tests.add(new Graph("random20B.txt"));
//        tests.add(new Graph("random30.txt"));
//        tests.add(new Graph("random50A.txt"));
//        tests.add(new Graph("random50B.txt"));
*/
//tests.add(new Graph("random20A.txt"));
tests.add(test);


        try{
          BufferedWriter flog = new BufferedWriter(new FileWriter(new File(log)));
          List<Long> l = new ArrayList<Long>();
          long t;
          long dans=0;
          long sans=0;
          for (Graph g : tests) {
              t = System.currentTimeMillis();
              flog.write(g.name+ "\n");
              dans=dcount.dcount(g);
              System.out.print("D: " + dans + " " + ((System.currentTimeMillis() - t) / 1000) + "\n");
              flog.write("D: " + dans + " " + ((System.currentTimeMillis() - t) / 1000) + "\n");
              for (int i = 0; i < 7; i++){
                t = System.currentTimeMillis();
                sans= scount.scount(g,eta);
                l.add( new Long(sans));
                flog.write("S: " + sans + " " + ((System.currentTimeMillis() - t) / 1000) + "\n");
              }
              Collections.sort(l);
              flog.write("Median: " + l.get(3) + " " + (int)((double)(l.get(3)-dans)/dans*100) +"% off\n");
          }
          flog.close();
        }
        catch( Exception e ){

          e.printStackTrace();
        }
    }
}
